/*     */ package dm.sql;
/*     */ 
/*     */ import dm.jdbc.dbaccess.Const;
/*     */ import dm.jdbc.dbaccess.DBError;
/*     */ import dm.jdbc.desc.BaseInfo;
/*     */ import dm.jdbc.desc.CommDesc;
/*     */ import dm.jdbc.innerData.DmdbConnAgent;
/*     */ import java.sql.Array;
/*     */ import java.sql.ResultSet;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Map;
/*     */ import java.util.ResourceBundle;
/*     */ 
/*     */ public class ARRAY extends TypeData implements Array
/*     */ {
/*     */   ArrayDescriptor m_arrDesc;
/*     */   TypeData[] m_arrData;
/*     */   Object m_objArray;
/*  19 */   final int ARRAY_MAX_ITEM_COUNT = 60000;
/*     */   
/*  21 */   int m_totalCount = 0;
/*  22 */   int m_index = 0;
/*  23 */   int m_countHasGet = 0;
/*     */   
/*     */   int m_itemCount;
/*     */   int m_itemSize;
/*  27 */   int m_objCount = 0;
/*  28 */   int m_strCount = 0;
/*  29 */   int[] m_objStrOffs = null;
/*     */   
/*     */   private void initData() {
/*  32 */     this.m_itemCount = 0;
/*  33 */     this.m_itemSize = 0;
/*  34 */     this.m_objCount = 0;
/*  35 */     this.m_strCount = 0;
/*  36 */     this.m_objStrOffs = null;
/*     */     
/*  38 */     this.m_dumyData = null;
/*  39 */     this.m_offset = 0;
/*     */     
/*  41 */     this.m_objArray = null;
/*     */   }
/*     */   
/*     */   public ARRAY(TypeData[] atData, TypeDescriptor desc) {
/*  45 */     super(null, null);
/*  46 */     this.m_arrDesc = new ArrayDescriptor(desc);
/*  47 */     this.m_arrData = atData;
/*     */   }
/*     */   
/*     */   void checkSArrayLen(int lenToCheck) throws SQLException {
/*  51 */     if (lenToCheck != this.m_arrDesc.getLength()) {
/*  52 */       DBError.throwSQLException(6036);
/*     */     }
/*     */   }
/*     */   
/*     */   public ARRAY(ArrayDescriptor arrDesc, DmdbConnAgent connAgent, Object[] objArr) throws SQLException
/*     */   {
/*  58 */     super(null, null);
/*     */     
/*  60 */     if (arrDesc == null) {
/*  61 */       DBError.throwSQLException(6036);
/*     */     }
/*  63 */     if ((connAgent == null) || (connAgent.getRealConn().isClosed())) {
/*  64 */       throw new SQLException(
/*  65 */         Const.res.getString("error.connectionClosedOrNotBuild"));
/*     */     }
/*  67 */     initData();
/*     */     
/*  69 */     this.m_arrDesc = arrDesc;
/*  70 */     if (objArr == null) {
/*  71 */       this.m_arrData = ((TypeData[])new Object[0]);
/*     */     }
/*     */     else {
/*  74 */       if (arrDesc.getMDesc().getDType() == 122)
/*     */       {
/*  76 */         if (objArr.length > arrDesc.getMDesc().getStaticArrayLength())
/*  77 */           throw new SQLException(
/*  78 */             Const.res.getString("error.invalidLenOfSARR"));
/*     */       }
/*  80 */       this.m_arrData = TypeData.toArray(objArr, this.m_arrDesc.getMDesc());
/*     */     }
/*     */     
/*  83 */     this.m_itemCount = this.m_arrData.length;
/*     */   }
/*     */   
/*     */   private void checkIndex(long index) throws SQLException {
/*  87 */     if ((index < 1L) || (index > this.m_arrData.length))
/*  88 */       DBError.throwSQLException(6057);
/*     */   }
/*     */   
/*     */   private void checkIndexAndCount(long index, int count) throws SQLException {
/*  92 */     checkIndex(index);
/*     */     
/*  94 */     if ((count <= 0) || (index - 1L + count > this.m_arrData.length))
/*  95 */       DBError.throwSQLException(6057);
/*     */   }
/*     */   
/*     */   public String getBaseTypeName() throws SQLException {
/*  99 */     return this.m_arrDesc.getItemDesc().getFulName();
/*     */   }
/*     */   
/*     */   public int getBaseType() throws SQLException {
/* 103 */     return dm.jdbc.driver.DmdbType.dtypeToSqlType(this.m_arrDesc.getItemDesc().getDType(), 
/* 104 */       getBaseTypeName());
/*     */   }
/*     */   
/*     */   public Object getArray() throws SQLException {
/* 108 */     if ((this.m_arrData == null) || (this.m_arrData.length <= 0)) {
/* 109 */       return null;
/*     */     }
/* 111 */     return toJavaArray(this, this.m_arrData.length, this.m_arrDesc.getItemDesc()
/* 112 */       .getDType());
/*     */   }
/*     */   
/*     */   public Object getArray(Map map) throws SQLException {
/* 116 */     DBError.throwUnsupportedSQLException();
/*     */     
/* 118 */     return null;
/*     */   }
/*     */   
/*     */   public Object getArray(long index, int count) throws SQLException {
/* 122 */     checkIndexAndCount(index, count);
/*     */     
/* 124 */     return toJavaArray(this, index, count, this.m_arrDesc.getItemDesc()
/* 125 */       .getDType());
/*     */   }
/*     */   
/*     */   public Object getArray(long index, int count, Map map) throws SQLException {
/* 129 */     DBError.throwUnsupportedSQLException();
/* 130 */     return null;
/*     */   }
/*     */   
/*     */   public int[] getIntArray() throws SQLException {
/* 134 */     return (int[])toNumericArray(this, 1L, this.m_itemCount, 
/* 135 */       2);
/*     */   }
/*     */   
/*     */   public int[] getIntArray(long index, int count) throws SQLException {
/* 139 */     checkIndexAndCount(index, count);
/*     */     
/* 141 */     return (int[])toNumericArray(this, index, count, 
/* 142 */       2);
/*     */   }
/*     */   
/*     */   public short[] getShortArray() throws SQLException {
/* 146 */     return (short[])toNumericArray(this, 1L, this.m_itemCount, 
/* 147 */       1);
/*     */   }
/*     */   
/*     */   public short[] getShortArray(long index, int count) throws SQLException {
/* 151 */     checkIndexAndCount(index, count);
/*     */     
/* 153 */     return (short[])toNumericArray(this, index, count, 
/* 154 */       1);
/*     */   }
/*     */   
/*     */   public long[] getLongArray() throws SQLException {
/* 158 */     return (long[])toNumericArray(this, 1L, this.m_itemCount, 
/* 159 */       3);
/*     */   }
/*     */   
/*     */   public long[] getLongArray(long index, int count) throws SQLException {
/* 163 */     checkIndexAndCount(index, count);
/*     */     
/* 165 */     return (long[])toNumericArray(this, index, count, 
/* 166 */       3);
/*     */   }
/*     */   
/*     */   public float[] getFloatArray() throws SQLException {
/* 170 */     return (float[])toNumericArray(this, 1L, this.m_itemCount, 
/* 171 */       4);
/*     */   }
/*     */   
/*     */   public float[] getFloatArray(long index, int count) throws SQLException {
/* 175 */     checkIndexAndCount(index, count);
/*     */     
/* 177 */     return (float[])toNumericArray(this, index, count, 
/* 178 */       4);
/*     */   }
/*     */   
/*     */   public double[] getDoubleArray() throws SQLException {
/* 182 */     return (double[])toNumericArray(this, 1L, this.m_itemCount, 
/* 183 */       5);
/*     */   }
/*     */   
/*     */   public double[] getDoubleArray(long index, int count) throws SQLException {
/* 187 */     checkIndexAndCount(index, count);
/*     */     
/* 189 */     return (double[])toNumericArray(this, index, count, 
/* 190 */       5);
/*     */   }
/*     */   
/*     */   public ResultSet getResultSet() throws SQLException {
/* 194 */     return new DmdbArrayDataResultSet(this);
/*     */   }
/*     */   
/*     */   public ResultSet getResultSet(Map map) throws SQLException {
/* 198 */     DBError.throwUnsupportedSQLException();
/* 199 */     return null;
/*     */   }
/*     */   
/*     */   public ResultSet getResultSet(long index, int count) throws SQLException {
/* 203 */     checkIndexAndCount(index, count);
/*     */     
/* 205 */     return new DmdbArrayDataResultSet(this, index, count);
/*     */   }
/*     */   
/*     */   public ResultSet getResultSet(long index, int count, Map map) throws SQLException
/*     */   {
/* 210 */     DBError.throwUnsupportedSQLException();
/* 211 */     return null;
/*     */   }
/*     */   
/*     */   public void free() throws SQLException {
/* 215 */     this.m_arrData = null;
/* 216 */     this.m_arrDesc = null;
/*     */     
/* 218 */     initData();
/*     */   }
/*     */   
/*     */   TypeData getData(long index, int col, Map map) throws SQLException
/*     */   {
/* 223 */     checkIndex(index);
/*     */     
/* 225 */     TypeData oneRow = this.m_arrData[((int)(index - 1L))];
/* 226 */     if ((oneRow.m_dumyData instanceof STRUCT)) {
/* 227 */       return ((STRUCT)oneRow.m_dumyData).getAttrValue(col);
/*     */     }
/* 229 */     return oneRow;
/*     */   }
/*     */   
/*     */   CommDesc getDataDesc(long index, int col) throws SQLException {
/* 233 */     checkIndex(index);
/*     */     
/* 235 */     CommDesc commDesc = new CommDesc();
/*     */     
/* 237 */     TypeDescriptor dataDesc = this.m_arrDesc.getItemDesc();
/* 238 */     if ((dataDesc.getDType() == 121) || 
/* 239 */       (dataDesc.getDType() == 119)) {
/* 240 */       TypeDescriptor[] attis = dataDesc.m_fieldsObj;
/*     */       
/*     */ 
/* 243 */       if ((col < 1) || (col > attis.length)) {
/* 244 */         DBError.throwSQLException(6032);
/*     */       }
/* 246 */       dataDesc = attis[(col - 1)];
/*     */     }
/*     */     
/* 249 */     commDesc.getBaseInfo().setDTypeInfo(dataDesc.m_dTypeInfo);
/* 250 */     commDesc.setLobDesc(dataDesc.m_lobDesc);
/*     */     
/* 252 */     return commDesc;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\sql\ARRAY.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */